package org.androidpn.server.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * entity 管理员
 * 
 * @author 蔡琪
 * 
 */
@Entity
@Table(name = "tk_admin")
public class Admin extends BaseEntity {

	private static final long serialVersionUID = -2274567109662972388L;

	/**
	 * enum 管理员状态
	 * 
	 * @author 蔡琪
	 * 
	 */
	public enum AdminStatus {
		/** 启用 */
		enable,
		/** 不可用 */
		disable,
		/** 锁定 */
		locked
	}

	/** 用户名 */
	@Column(name = "username", unique = true, nullable = false, length = 16)
	private String username;

	/** 密码 */
	@Column(name = "password", nullable = false)
	private String password;

	/** 上一次登录ip */
	@Column(name = "last_login_ip")
	private String lastLoginIp;

	/** 状态 */
	@Column(name = "status")
	private AdminStatus status;

	/** 广播 */
	@OneToMany(cascade = CascadeType.REMOVE, mappedBy = "admin", fetch = FetchType.LAZY)
	private Set<Broadcast> broadcasts = new HashSet<Broadcast>();

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}

	public AdminStatus getStatus() {
		return status;
	}

	public void setStatus(AdminStatus status) {
		this.status = status;
	}

	public Set<Broadcast> getBroadcasts() {
		return broadcasts;
	}

	public void setBroadcasts(Set<Broadcast> broadcasts) {
		this.broadcasts = broadcasts;
	}

}
